package com.jz.netthings.application.providerReg.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.jz.netthings.application.providerReg.bean.ProviderReg;
import com.jz.netthings.application.providerReg.bean.QueryProviderReg;
import com.jz.netthings.application.providerReg.service.ProviderRegService;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.security.utils.Token;
import com.jz.netthings.support.SimpleCoreResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyl
 * @since 2019-02-28
 */
@RestController
@RequestMapping("/adscm/application/providerReg")
public class ProviderRegController {

    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    @Autowired
    ProviderRegService providerRegService;

    @RequestMapping("/select")
    public SimpleCoreResponse selectByTime(@RequestBody QueryProviderReg queryProviderReg, HttpServletRequest request) throws AdscmSystemException, IOException {
        Page<ProviderReg> page =new Page<>(queryProviderReg.getCurrentPage(),queryProviderReg.getPageSize());
        Page<ProviderReg> providerRegs = providerRegService.selectByTime(page ,queryProviderReg);
        return new SimpleCoreResponse("200","查询成功" ,providerRegs);
    }
    @RequestMapping("/selectProviderReg/{registerNo}")
    public SimpleCoreResponse selectProviderReg(@PathVariable String registerNo , HttpServletRequest request) throws AdscmSystemException, IOException {
        ProviderReg providerReg = providerRegService.selectProviderReg(registerNo);
        return new SimpleCoreResponse("200","查询成功" ,providerReg);
    }

}

